<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Demo3</title>
    <link rel="stylesheet" href="./Demo3.css">
    <style>
        .light{
            background-color: white;
            color: black;
            width: 100%;
            height: 100%;
        }
        .dark{
            background-color: black;
            color: white;
            width: 100%;
            height: 100%;
        }
        body,html{
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
    <!-- 1.行内样式操作 -->
    <div id="demo1" style="font-size: 10px;">
        Hello World
    </div>
    <!-- 2.类名/id样式操作 -->
    <div id="demo2" class="light">
        九转苍翎
    </div>
</body>
<script>
    //1.行内样式操作
    let demo1 = document.querySelector("#demo1");
    //console.log(typeof(demo1.style.fontSize));//string
    demo1.onclick = function(){
        //console.log(demo1.style);
        demo1.style.fontSize = (parseInt(demo1.style.fontSize) + 10) + "px";
    }
    //2.类名/id样式操作
    let demo2 = document.querySelector("#demo2");
    demo2.onclick = function(){
        if(demo2.className === "light"){
            demo2.className = "dark";
        }else{
            demo2.className = "light";
        }
    }
</script>
</html>